<template>
  <div class="child">
      <h2>子组件1</h2>
      <h4>玩具：{{ toy }}</h4>
      <h4>书籍：{{ book }}</h4>
      <button @click="changeHouse($parent)">干掉父亲的一套房子</button>
  </div>
</template>

<script setup lang="ts">
import { ref } from 'vue'
const toy = ref('变形金刚')
const book = ref('三国演义')

function changeHouse(parent: any) {
  parent.house -= 1
}

// 把数据暴露给父组件
defineExpose({
  toy,
  book
})
</script>

<style scoped>
.child {
  padding: 10px;
  box-shadow: 0 0 10px 0 rgba(0, 0, 0, 0.1);
  background-color: skyblue;
  border-radius: 10px;
}
</style>